package com.qf.service.impl;

import com.qf.commo.utils.R;
import com.qf.entity.Permission;
import com.qf.entity.User;
import com.qf.mapper.IAuthMapper;
import com.qf.service.IAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IAuthServiceImpl implements IAuthService {
    @Autowired
    private IAuthMapper authMapper;

    @Override
    public Boolean unAuthRoleToUser(Integer uid, Integer rid) {
        return authMapper.unAuthRoleToUser(uid,rid);
    }

    @Override
    public void authRoleToUser(Integer roleId, List<User> list) {
        authMapper.batchUnAuthRoleToUser(roleId,list);
        authMapper.authRoleToUser(roleId,list);
    }

    @Override
    public List<Integer> getRoleMenuList(Integer roleId) {
        return authMapper.getRoleMenuList(roleId);
    }

    @Override
    public Boolean authMenuToroleUpdate(Integer roleId,List<Integer> menuList) {
            //1.先删除用户所有权限
            authMapper.unAuthMenuToRole(roleId);
          //2.在添加新的权限

        return authMapper.authMenuToroleUpdate(roleId,menuList);
    }


}
